//
//  LHRecommendHotelTableViewCell.m
//  Knight_Tour
//
//  Created by 庞魁 on 15-5-16.
//  Copyright (c) 2015年 TouchOne. All rights reserved.
//

#import "LHRecommendHotelTableViewCell.h"
#import "UIImageView+WebCache.h"

@interface LHRecommendHotelTableViewCell ()

@property (nonatomic, retain) UILabel *hotelName;
@property (nonatomic, retain) UIImageView *hotelPic;
@property (nonatomic, retain) UIImageView *starLevelPic;
@property (nonatomic, retain) UILabel *starLevel;
@property (nonatomic, retain) UILabel *hotelAddress;



@end

@implementation LHRecommendHotelTableViewCell

- (void)dealloc
{
    [_hotelPic release];
    [_hotelName release];
    [_hotelAddress release];
    [_starLevel release];
    [_starLevelPic release];
    [super dealloc];
}

/**
 *  初始化 设置控件
 */

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.hotelName = [[UILabel alloc] init];
        
        [self.contentView addSubview:_hotelName];
        
        [_hotelName setFont:[UIFont fontWithName:@"Helvetica-Bold" size:17]];
        
        [_hotelName release];
        
        
        self.hotelPic = [[UIImageView alloc] init];
        
        self.hotelPic.layer.cornerRadius = 7;
        self.hotelPic.clipsToBounds = YES;
        
        [self.contentView addSubview:_hotelPic];
        
        [_hotelPic release];
        
        
        self.hotelAddress = [[UILabel alloc] init];
        
        [self.contentView addSubview:_hotelAddress];
        
        [_hotelAddress setFont:[UIFont fontWithName:@"Helvetica-Bold" size:13]];
        
        [_hotelAddress release];
        
        
        self.starLevelPic = [[UIImageView alloc] init];
        
        [self.contentView addSubview:_starLevelPic];
        
//        _starLevelPic.backgroundColor = [UIColor colorWithRed:0.099 green:0.760 blue:0.974 alpha:1.000];
        
        [_starLevelPic release];
        
        
        self.starLevel = [[UILabel alloc] init];
        
        [self.contentView addSubview:_starLevel];
        
        [_starLevel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:13]];
        
        [_starLevel release];
        

        
    
        
    }
    
    return self;
}

/**
 *  设置控件布局信息
 */

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    _hotelName.frame = CGRectMake(10, 5, 200, 30);
    
    _hotelPic.frame = CGRectMake(10, _hotelName.frame.origin.y + 35, self.frame.size.width / 3, self.frame.size.width / 3);
    
    
    _starLevelPic.frame = CGRectMake(_hotelPic.frame.origin.x + self.frame.size.width / 3 + 20, _hotelPic.frame.origin.y - 10, 60, 50);
    
    _starLevel.frame = CGRectMake(_hotelPic.frame.origin.x + self.frame.size.width / 3 + 20, _starLevelPic.frame.origin.y + self.frame.size.width / 9, 120, 20);
    
    
    _hotelAddress.frame = CGRectMake(_hotelPic.frame.origin.x + self.frame.size.width / 3 + 20, _starLevel.frame.origin.y + self.frame.size.width / 9, 150, 40);

    
}

// 重写setter方法
- (void)setRecHotelModel:(LHRecommendHotelModel *)recHotelModel
{
    if (_recHotelModel != recHotelModel) {
        
        [_recHotelModel release];
        
        _recHotelModel = [recHotelModel retain];
    }
    
    _hotelName.text = recHotelModel.name;
    
    [_hotelPic sd_setImageWithURL:[NSURL URLWithString:recHotelModel.cover_s] placeholderImage:[UIImage imageNamed:@"word4"]];
    
    
    
    _hotelAddress.text = recHotelModel.address;
    _hotelAddress.numberOfLines = 3;
    [_hotelAddress setFont:[UIFont systemFontOfSize:13]];
    
    _starLevel.text = @"三星级";
    [_starLevel setFont:[UIFont systemFontOfSize:13]];

    _starLevelPic.image = [UIImage imageNamed:@"xingji"];
    
}





- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
